package com.techstar.api.service;

import com.techstar.api.service.city_external.*;
import com.techstar.api.service.hinge_external.*;
import com.techstar.api.service.hinge_situation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import lombok.extern.slf4j.Slf4j;

import java.util.Arrays;
import java.util.List;

/**
 * 
 * @author EinIce
 * @description API接口启动配置
 * @date 2021年9月9日
 */
@Slf4j
@Service
public class TrafficFactory {
//	private List<String> distId = Arrays.asList("4553","5318","5319","5320","5321","5322","5323","5324","5325","5326");
//	4.3.2.3 各类型货物吞吐量及周转量的hub_type
	private List<String> hub_type_5 = Arrays.asList("000","100","200","300","400");
	private List<String> hub_type_4 = Arrays.asList("100","200","300","400");
	private List<String> orders = Arrays.asList("1","2");

	@Autowired
	private CityExternalAreaOdRankOutService CityExternalAreaOdRankOutService;
	@Autowired
	private CityExternalAreaOdRankInService CityExternalAreaOdRankInService;
	@Autowired
	private CityExternalContainerThroughputTrendService CityExternalContainerThroughputTrendService;
	@Autowired
	private CityExternalContainerVolumeService CityExternalContainerVolumeService;
	@Autowired
	private CityExternalFreightThroughputTrendService CityExternalFreightThroughputTrendService;
	@Autowired
	private CityExternalFreightVolumeService CityExternalFreightVolumeService;
	@Autowired
	private CityExternalPassengerVolumeService CityExternalPassengerVolumeService;
	@Autowired
	private CityExternalPassengerVolumeTrendService CityExternalPassengerVolumeTrendService;
	@Autowired
	private CityExternalProvinceOdRankOutService CityExternalProvinceOdRankOutService;
	@Autowired
	private CityExternalProvinceOdRankInService CityExternalProvinceOdRankInService;
	@Autowired
	private CityExternalRealtimeFreightVolumeService CityExternalRealtimeFreightVolumeService;
	@Autowired
	private CityExternalRealtimePassengerVolumeService CityExternalRealtimePassengerVolumeService;
	
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void CityExternalService() {
		log.info("CityExternal Server Start!");

		CityExternalContainerThroughputTrendService.query();
		CityExternalContainerVolumeService.query();
		CityExternalFreightThroughputTrendService.query();
		CityExternalFreightVolumeService.query();
		CityExternalPassengerVolumeService.query();
		CityExternalPassengerVolumeTrendService.query();
//		CityExternalProvinceOdRankService.query();
//		CityExternalAreaOdRankService.query();

		CityExternalAreaOdRankOutService.query();
		CityExternalAreaOdRankInService.query();
		CityExternalProvinceOdRankOutService.query();
		CityExternalProvinceOdRankInService.query();

		// 新版本中已经删除了这两个接口

	//	CityExternalRealtimeFreightVolumeService.query();
	//	CityExternalRealtimePassengerVolumeService.query();
		log.info("CityExternal Server Finish!");
	}
	
	@Autowired
	private HingeExternalContainerThroughputTrendService HingeExternalContainerThroughputTrendService;
	@Autowired
	private HingeExternalContainerVolumeService HingeExternalContainerVolumeService;
	@Autowired
	private HingeExternalFreightThroughputTrendService HingeExternalFreightThroughputTrendService;
	@Autowired
	private HingeExternalFreightVolumeService HingeExternalFreightVolumeService;
	@Autowired
	private HingeExternalIndividualContainerThroughputTrendService HingeExternalIndividualContainerThroughputTrendService;
	@Autowired
	private HingeExternalIndividualContainerVolumeService HingeExternalIndividualContainerVolumeService;
	@Autowired
	private HingeExternalIndividualEventService HingeExternalIndividualEventService;
	@Autowired
	private HingeExternalIndividualFreightThroughputTrendService HingeExternalIndividualFreightThroughputTrendService;
	@Autowired
	private HingeExternalIndividualFreightVolumeService HingeExternalIndividualFreightVolumeService;
	@Autowired
	private HingeExternalIndividualPassengerVolumeService HingeExternalIndividualPassengerVolumeService;
	@Autowired
	private HingeExternalIndividualPassengerVolumeTrendService HingeExternalIndividualPassengerVolumeTrendService;
	@Autowired
	private HingeExternalIndividualPredictPassengerVolumeService HingeExternalIndividualPredictPassengerVolumeService;
	@Autowired
	private HingeExternalIndividualProvinceOdRankService HingeExternalIndividualProvinceOdRankService;
	@Autowired
	private HingeExternalIndividualRealtimeCapacityService HingeExternalIndividualRealtimeCapacityService;
	@Autowired
	private HingeExternalIndividualRealtimeDispatchService HingeExternalIndividualRealtimeDispatchService;
	@Autowired
	private HingeExternalIndividualRealtimeFreightVolumeService HingeExternalIndividualRealtimeFreightVolumeService;
	@Autowired
	private HingeExternalIndividualRealtimePassengerVolumeService HingeExternalIndividualRealtimePassengerVolumeService;
	@Autowired
	private HingeExternalPassengerCountService HingeExternalPassengerCountService;
	@Autowired
	private HingeExternalPassengerVolumeService HingeExternalPassengerVolumeService;
	@Autowired
	private HingeExternalPassengerVolumeTrendService HingeExternalPassengerVolumeTrendService;
	@Autowired
	private HingeExternalProvinceOdRankService HingeExternalProvinceOdRankService;
	@Autowired
	private HingeExternalProvinceOdRankInService HingeExternalProvinceOdRankInService;
	@Autowired
	private HingeExternalRealtimeDispatchService HingeExternalRealtimeDispatchService;
	@Autowired
	private HingeExternalRealtimeFreightVolumeService HingeExternalRealtimeFreightVolumeService;
	@Autowired
	private HingeExternalRealtimePassengerVolumeService HingeExternalRealtimePassengerVolumeService;

	@Autowired
	private HingeExternalIndividualProvinceOdRankOutService hingeExternalIndividualProvinceOdRankOutService;
	@Autowired
	private HingeExternalIndividualProvinceOdRankInService hingeExternalIndividualProvinceOdRankInService;


	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void HingeExternalService() {
		log.info("HingeExternal Server Start!");
		HingeExternalContainerThroughputTrendService.query();
//		HingeExternalIndividualContainerThroughputTrendService.query();
//		HingeExternalIndividualContainerVolumeService.query();
		HingeExternalIndividualEventService.query();
//		HingeExternalIndividualFreightThroughputTrendService.query();
//		HingeExternalIndividualFreightVolumeService.query();
//		HingeExternalIndividualPassengerVolumeService.query();
//		HingeExternalIndividualPassengerVolumeTrendService.query();
//		HingeExternalIndividualPredictPassengerVolumeService.query();
//		HingeExternalIndividualProvinceOdRankService.query();
//		HingeExternalIndividualRealtimeCapacityService.query();
//		HingeExternalIndividualRealtimeDispatchService.query();
//		HingeExternalIndividualRealtimeFreightVolumeService.query();
//
//		hub_type_4.forEach(l -> HingeExternalIndividualContainerThroughputTrendService.query(l));
//		hub_type_4.forEach(l -> HingeExternalIndividualContainerVolumeService.query(l));
//		hub_type_4.forEach(l -> HingeExternalIndividualFreightThroughputTrendService.query(l));
//		hub_type_4.forEach(l -> HingeExternalIndividualFreightVolumeService.query(l));
//		hub_type_4.forEach(l -> HingeExternalIndividualPassengerVolumeService.query(l));
//		hub_type_4.forEach(l -> HingeExternalIndividualPassengerVolumeTrendService.query(l));
//		hub_type_4.forEach(l -> HingeExternalIndividualPredictPassengerVolumeService.query(l));//The API does not exist or has not been published in the environment
//		for (String o : orders) {
//			hub_type_4.forEach(l -> HingeExternalIndividualProvinceOdRankService.query(l, o));
//		}
//		hub_type_4.forEach(l -> HingeExternalIndividualRealtimeCapacityService.query(l));//The API does not exist or has not been published in the environment
//		hub_type_4.forEach(l -> HingeExternalIndividualRealtimeDispatchService.query(l));

		HingeExternalIndividualContainerThroughputTrendService.query("300");
		HingeExternalIndividualContainerVolumeService.query("300");
		HingeExternalIndividualEventService.query();
		HingeExternalIndividualFreightThroughputTrendService.query("300");
		HingeExternalIndividualFreightVolumeService.query("300");
		HingeExternalIndividualPassengerVolumeService.query("300");
		HingeExternalIndividualPassengerVolumeTrendService.query("300");
		HingeExternalIndividualPredictPassengerVolumeService.query("300");//The API does not exist or has not been published in the environment
		hingeExternalIndividualProvinceOdRankOutService.query("300");
		hingeExternalIndividualProvinceOdRankInService.query("300");
		HingeExternalIndividualRealtimeCapacityService.query("300");//The API does not exist or has not been published in the environment
		HingeExternalIndividualRealtimeDispatchService.query("300");
		HingeExternalIndividualRealtimeFreightVolumeService.query();//接口文档删除


		HingeExternalRealtimeFreightVolumeService.query();
		HingeExternalRealtimePassengerVolumeService.query();
		HingeExternalFreightThroughputTrendService.query();
		HingeExternalPassengerVolumeTrendService.query();
//		HingeExternalContainerVolumeService.query();
//		HingeExternalIndividualRealtimePassengerVolumeService.query();
//		HingeExternalPassengerCountService.query();
//		HingeExternalPassengerVolumeService.query();
//		HingeExternalRealtimeDispatchService.query();
//		HingeExternalProvinceOdRankService.query();
//		HingeExternalFreightVolumeService.query();
//      按hub_type 类型依次请求数据
//		hub_type_4.forEach(l->HingeExternalPassengerVolumeTrendService.query(l));
//		hub_type_4.forEach(l->HingeExternalFreightThroughputTrendService.query(l));
		hub_type_4.forEach(l->HingeExternalIndividualRealtimePassengerVolumeService.query(l));
		hub_type_4.forEach(l->HingeExternalPassengerCountService.query(l));
		hub_type_4.forEach(l->HingeExternalRealtimeDispatchService.query(l));
		hub_type_4.forEach(l->HingeExternalProvinceOdRankService.query(l)); //累计旅客出发量
		hub_type_4.forEach(l-> HingeExternalProvinceOdRankInService.query(l)); // 累计旅客到达量
		hub_type_5.forEach(l->HingeExternalContainerVolumeService.query(l));
		hub_type_5.forEach(l->HingeExternalFreightVolumeService.query(l));
		hub_type_5.forEach(l->HingeExternalPassengerVolumeService.query(l));


		log.info("HingeExternal Server Finish!");
	}
	
	@Autowired
	private HingeSituationContainerVolumeRankService HingeSituationContainerVolumeRankService;
	@Autowired
	private HingeSituationEventService HingeSituationEventService;
	@Autowired
	private HingeSituationFreightVolumeRankService HingeSituationFreightVolumeRankService;
	@Autowired
	private HingeSituationPassengerVolumeRankService HingeSituationPassengerVolumeRankService;


	@Autowired
	private HingeSituationFreightVolumeService HingeSituationFreightVolumeService;
	@Autowired
	private HingeSituationPassengerVolumeService HingeSituationPassengerVolumeService;
	@Autowired
	private HingeSituationContainerVolumeService HingeSituationContainerVolumeService;

	@Autowired
	private HingeSituationRealtimeCapacityService HingeSituationRealtimeCapacityService;
	@Autowired
	private HingeSituationRealtimeDispatchService HingeSituationRealtimeDispatchService;
	@Autowired
	private HingeSituationRealtimePassengerVolumeService HingeSituationRealtimePassengerVolumeService;
	
	@Scheduled(fixedDelay = 1 * 60 * 1000)
	public void HingeSituationService() {
		log.info("HingeSituation Server Start!");
//		HingeSituationContainerVolumeService.query();
//		HingeSituationEventService.query();
//		HingeSituationFreightVolumeService.query();
//		HingeSituationPassengerVolumeService.query();
//		HingeSituationRealtimeCapacityService.query();
//		HingeSituationRealtimeDispatchService.query();
//		TOP排名
		hub_type_4.forEach(l-> HingeSituationContainerVolumeRankService.query(l));
		hub_type_4.forEach(l-> HingeSituationFreightVolumeRankService.query(l));
		hub_type_4.forEach(l-> HingeSituationPassengerVolumeRankService.query(l));
//		 变化趋势
		hub_type_4.forEach(l-> HingeSituationContainerVolumeService.query(l));
		hub_type_4.forEach(l-> HingeSituationFreightVolumeService.query(l));
		hub_type_4.forEach(l-> HingeSituationPassengerVolumeService.query(l));






		// api 不存在
	//	HingeSituationRealtimePassengerVolumeService.query();
		log.info("HingeSituation Server Finish!");
	}
}
